<?php

class Rols extends Onecore_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model("rols_model");
        $this->_moduleName = utf8_encode("Administración de Roles");
        $this->_moduleDescription = utf8_encode("Description") . $this->_moduleName;
        $this->_modelInstance = $this->rols_model;
    }
    public function loadList() {
        $cfg = $this->config->item('defaultCfg');

        $options = new stdClass();
        $options->conditions = new stdClass();
        $options->start = $this->input->get('start');
        $options->limit = $this->input->get('limit');
        $options->conditions->isSystem = $this->input->get('isSystem');
        $options->conditions->deleted = "";

        if (!$this->input->get('sort')) {
            $options->orderField = 'id';
            $options->orderDirection = 'DESC';
        } else {
            $orden = $this->input->get('sort');
            $sort = json_decode($orden);
            $options->orderField = $sort[0]->property;
            $options->orderDirection = $sort[0]->direction;
        }

        $data = $this->_modelInstance->listEntities($options);

        $res = array(
            "success" => true,
            "results" => $data['results'],
            "rows" => $data['items']
        );
        $this->layout->printLike(json_encode($res), "json");
    }
}

